  //获取应用实例
let app = getApp();
let FormCheckRule = {
	telRule: /^[1]{1}[0-9]{10}$/,
	idCardRule1: /^[0-9]{14}([0-9]|X|x)$/,
	idCardRule2: /^[0-9]{17}([0-9]|X|x)$/,
    nameRule: /^[\u4e00-\u9fa5]{2,12}$/,
	//非专业
	archivesNullMessage: '请输入指标档案号',
	archivesErrorMessage: '请输入正确的指标档案号',
	cardFixNullMessage: '请输入内地牌号',
	cardFixErrorMessage: '请输入正确的内地牌号',
	frameNullMessage: '请输入车架号后6位',
	frameErrorMessage: '请输入正确的车架号',
	codeNullMessage: '请输入验证码',
	codeErrorMessage: '请输入正确的验证码',
	phoneNullMessage: '请输入内地手机号码',
	phoneErrorMessage: '请输入正确的内地手机号码',
	phoneCodeNullMessage: '请输入手机验证码',
	phoneCodeErrorMessage: '请输入正确的手机验证码',
	//专业
	dossierNullMessage: '请输入卷宗号',
	dossierErrorMessage: '请输入正确的卷宗号',
	idCardNullMessage: '请输入办证员身份证号码',
	idCardErrorMessage: '请输入正确的办证员身份证号码',
	nameNullMessage: '请输入办证员姓名',
	nameErrorMessage: '请输入正确的办证员姓名',
	majorCodeNullMessage: '请输入验证码',
	majorCodeErrorMessage: '请输入正确的验证码',
	majorPhoneNullMessage: '请输入内地手机号码',
	majorPhoneErrorMessage: '请输入正确的内地手机号码',
	majorPhoneCodeNullMessage: '请输入手机验证码',
	majorPhoneCodeErrorMessage: '请输入正确的手机验证码',
	errorFocusName: '', //输入检验样式
	checkService: '请阅读并同意《法律声明》'
};
var isShowRender = true;
Page({
	data: {
		countDown: '获取验证码',
		majorCountDown: '获取验证码', //专业运输公司
		tagData: [
			{text: '非专业运输公司车辆', index: 1},
			{text: '专业运输公司车辆', index: 2}
		],
		//非专业公司参数
		archives: '', //受理编号
		preFix: 'Z', //默认前缀
		cardFix: '', //车牌号
		frame: '', //车架号
		code: '', //验证码
		phone: '', //内地手机号码
		phoneCode: '', //手机验证码
		validateCode: '', ////验证码
		codeImg: '', //验证码图片
		//专业公司参数
		dossier: '', //卷宗号
		idCard: '', //身份证
		name: '', //姓名
		majorCode: '', //验证码
		majorPhone: '',//内地手机号码
		majorPhoneCode: '',//手机验证码
		isShowFrame: false, //车身架号是否显示
		majorValidateCode : '', //验证码
		isShowMajorCode: false, //验证码弹框
		majorCodeImg: '', //验证图片

		needInvoice: 1,  //是否勾选
    	isCanScroll: true, //屏幕是否能够滑动
		isShowFootNav: true,  //底部导航菜单
		tagAction: 1, //顶部导航默认选项
		preFixList: [
			{name: '粤Z',key: 'Z'}
		],
		isShowView: false, //车牌前缀列表蒙层
		num: 0  //订单数
	},	
	//校验验证码图片事件
	checkMajorVerificationCode() {
		let code = this.data.majorValidateCode;
		if (!code) {
			app.errorToast('验证码不能为空');
			return;
		}
	},
	//获取验证码图片事件
	verificationCode() {
		let { tagAction ,phone, majorPhone} = this.data;
		let tel = tagAction == 1? phone:majorPhone;
		let getCodeImg = app.globalData.host+"/img/imageCode.ajax?phoneNumber=" + tel +'&random=' + Math.floor(Math.random()*10+1);
		if (tagAction == 1) {
			this.setData({
				codeImg: getCodeImg
			})
		} else {
			this.setData({
				majorCodeImg: getCodeImg
			})
		}
	},
	hideMajorCodeMask() {
		this.setData({
			isShowMajorCode: false,
			majorValidateCode: '', //清空验证码输入框
			isShowFootNav: true
		})
	},
	//专业公司倒计时
	majorCountDown() {
		let { majorPhoneIconType, majorPhone, majorCountDown} = this.data;
		if (majorPhoneIconType == 'error' || majorPhone == '') {
			app.errorToast('请输入手机号码');
			this.setData({
				errorFocusName: 'majorPhone'
			})
			return;
		}
		if (majorCountDown === "获取验证码" || majorCountDown === "重新发送") {
			/*
			this.verificationCode()
			this.setData({
				isFocusMajor: true,
				isShowMajorCode: true,
				isShowFootNav: false 
			});
			*/
			this.majorCheckCode();
		}
	},
	//非专业
	checkCode() {
		let { countDown, phone, validateCode } = this.data;
		this.checkVerificationCode('noMaJor', phone, validateCode, () => {
			if (countDown === "获取验证码" || countDown === "重新发送") {
				let second = 59; //用来记录秒
				this.setData({
					countDown: second + 's'
				})
				let SEND = setInterval(() => {
					second--;
					this.setData({
						countDown: second + 's'
					})
					if (second == 0) {
						this.setData({
							countDown: '重新发送'
						})
						clearInterval(SEND);
					} //到过60秒时停止
				}, 1000); //每1000毫秒即1秒执行一次此函数
			}
		})
	},
	//专业校验事件
	majorCheckCode() {
		let { majorCountDown, majorPhone, majorValidateCode} = this.data;
		this.checkVerificationCode('maJor', majorPhone, majorValidateCode, () => {
			if (majorCountDown === "获取验证码" || majorCountDown === "重新发送") {
				let second = 59; //用来记录秒
				this.setData({
					majorCountDown: second + 's'
				})
				let SEND = setInterval(() => {
					second--;
					this.setData({
						majorCountDown: second + 's'
					})
					if (second == 0) {
						this.setData({
							majorCountDown: '重新发送'
						})
						clearInterval(SEND);
					} //到过60秒时停止
				}, 1000); //每1000毫秒即1秒执行一次此函数
			}
		})
	},
	//校验验证码图片事件
	checkVerificationCode(type, phone, imageCode, callBack) {
		/*
		if (!imageCode) {
			app.errorToast('验证码不能为空');
			if (type == 'maJor') { //专业
				this.setData({
					isFocusMajor: true
				})
			} else {
				this.setData({
					isFocus: true
				})
			}
			return;
		}
		*/
		let that = this;
		let opt = {
			url: app.globalData.host+"/wx/c/vc.ajax",
			data: {
				phoneNumber: phone,
				// imageCode: imageCode,
				bizFlag: 0
			},
			sucFn: (result) => {
				if (type == 'maJor') { //专业
					that.setData({
						majorValidateCode: '', //清空
						isShowMajorCode: false
					})
				} else {
					that.setData({
						validateCode: '', //清空
						isShowCode: false
					})
				}
				that.setData({
					isShowFootNav: true
				})
				typeof(callBack) == 'function'&&callBack()
			}
		};
		app.ajax(opt);
	},
	hideCodeMask() {
		this.setData({
			isShowCode: false,
			validateCode: '', //清空验证码输入框
			isShowFootNav: true
		})
	},
	//非专业公司输入验证码蒙层
	countDown() {
		let { phoneIconType, phone, countDown} = this.data;
		if (phoneIconType == 'error' || phone == '') {
			app.errorToast('请输入手机号码');
			this.setData({
				errorFocusName: 'phone'
			})
			return;
		}
		if (countDown === "获取验证码" || countDown === "重新发送") {
			// this.verificationCode()
			// this.setData({
			// 	isFocus: true,
			// 	isShowCode: true,
			// 	isShowFootNav: false 
			// })
			this.checkCode();
		}
	},

	/*-----------非专业事件--------------*/
	//车牌号码只能输入大写
	infoProFix(e) {
        let pattern = /([^A-Za-z0-9]|\s)*/g,
			value = e.detail.value.replace(/(^\s*)|(\s*$)/g,"");
        if (value.length <= 4) {
			value = value.replace(pattern, "").replace("I", 1).replace("O", 0).toUpperCase();
			this.setData({
				cardFix: value
			});
			if (value.length) {
				this.setData({
					isShowFrame: true
				})
			} else {
				this.setData({
					isShowFrame: false
				})
			}
		}	
		this.setData({
			cardFix: value
		});
		if (value == '') {
			this.setData({cardNbrIconType: "success"});
		} else if (value.length < 5){
			this.setData({cardNbrIconType: "error"});
		} else {
			this.setData({cardNbrIconType: "success"});
		}	
    },

	//选择车牌
	checkPreFix(e) {
		let name = e.detail.name;
		if (name) {
			this.setData({
				preFix: name,
				isShowView: false,
				isShowFootNav: true
			})
		} else {
			this.setData({
				isShowView: false,
				isShowFootNav: true
			})
		}
	},
	//点击车牌前缀
	provinceName(e) {
        this.setData({
            isShowView: true,
            isShowFootNav:false
        })
    },

	//指标档案号 条形码
	bindViewTap() {
        let that = this,
			path= /^[0-9a-zA-Z]*$/g;
        wx.scanCode({
            success: (res) => {
				if (path.test(res.result)) {
					setTimeout(() => {
						that.setData({
							archives: res.result
						});
					}, 500);
				} else {
					app.errorToast(FormCheckRule.archivesErrorMessage);
				}
            }
        })
	},
	//卷宗号 条形码
	bindViewDossierTap() {
		let that = this,
		path= /^[0-9a-zA-Z]*$/g;
		wx.scanCode({
			// onlyFromCamera: true,
			success: (res) => {
				if (path.test(res.result)) {
					setTimeout(() => {
						that.setData({
							dossier: res.result
						});
					}, 600);
				} else {
					app.errorToast(FormCheckRule.dossierErrorMessage);
				}
			}
		})
	},
	
	//输入框公用方法
    infoInput(e) {
        let id = e.currentTarget.id,
			value = e.detail.value.replace(/(^\s*)|(\s*$)/g,"");
		//非专业车辆
        if (id == "archives") { //档案号
            let pattern = /([^A-Za-z0-9]|\s)*/g,
			value = e.detail.value.replace(pattern, '');
			this.setData({archives: value});
		} else if (id == 'frame') { //车架号后六位
			let pattern = /([^A-Za-z0-9]|\s)*/g,
			value = e.detail.value.replace(pattern, '');
            this.setData({frame: value});
			if (value=='') {
                this.setData({frameIconType: "success"});
            } else if (value.length<6) {
                this.setData({frameIconType: "error"});
            } else {
                this.setData({frameIconType: "success"});
            }
		} else if (id == 'code') { //验证码
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = e.detail.value.replace(pattern,'');
            this.setData({code: value});
			if (value=='') {
                this.setData({codeIconType: "success"});
            } else if (value.length<4){
                this.setData({codeIconType: "error"});
            } else {
                this.setData({codeIconType: "success"});
            }
		} else if(id == "phone") { //内地手机号码
            value = value.substr(0, 11);
            this.setData({phone: value});
            if(value==''){
                this.setData({phoneIconType: "success"});
            }else if (FormCheckRule.telRule.test(value)) {
                this.setData({phoneIconType: "success"});
            } else if (value.length > 0) {
                this.setData({phoneIconType: "error"});
            } else {
                this.setData({phoneIconType: ""});
            }
        } else if (id == 'phoneCode') {
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = value.replace(pattern,'');
			this.setData({phoneCode: value});
			if (value=='') {
                this.setData({phoneCodeIconType: "success"});
            } else if (value.length<6) {
                this.setData({phoneCodeIconType: "error"});
            } else {
                this.setData({phoneCodeIconType: "success"});
            }
		} else if (id == 'validateCode') { //验证码
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = value.replace(pattern,'');
			this.setData({validateCode: value})
		}
		//专业车辆
		else if (id == 'dossier') {
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = value.replace(pattern,'');
            this.setData({dossier: value});
		} else if (id == 'idCard') {
			value = value.replace('x', 'X');
            this.setData({idCard: value});
			if ( value == '' || value.length == 15 && FormCheckRule.idCardRule1.test(value)) {
                this.setData({idCardIconType: "success"});
            } else if (value == '' || value.length == 18 && FormCheckRule.idCardRule2.test(value)) {
                this.setData({idCardIconType: "success"});
            } else if (value.length>0) {
                this.setData({idCardIconType: "error"});
            }else {
                this.setData({idCardIconType: ""});
            }
		} else if (id == 'name') {
			this.setData({name: value});
		} else if (id == 'majorCode') { //验证码
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = e.detail.value.replace(pattern,'');
            this.setData({majorCode: value});
			if (value=='') {
                this.setData({majorCodeIconType: "success"});
            } else if (value.length<4){
                this.setData({majorCodeIconType: "error"});
            } else {
                this.setData({majorCodeIconType: "success"});
            }
		} else if(id == "majorPhone") { //内地手机号码
            value = value.substr(0, 11);
            this.setData({majorPhone: value});
            if (value=='') {
                this.setData({majorPhoneIconType: "success"});
            } else if (FormCheckRule.telRule.test(value)) {
                this.setData({majorPhoneIconType: "success"});
            } else if (value.length > 0) {
                this.setData({majorPhoneIconType: "error"});
            } else {
                this.setData({majorPhoneIconType: ""});
            }
        } else if (id == 'majorPhoneCode') {
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = value.replace(pattern,'');
            this.setData({majorPhoneCode: value});
			if (value=='') {
                this.setData({majorPhoneCodeIconType: "success"});
            } else if (value.length < 6) {
                this.setData({majorPhoneCodeIconType: "error"});
            } else {
                this.setData({majorPhoneCodeIconType: "success"});
            }
		} else if (id == 'majorValidateCode') { //验证码
			let pattern = /([^A-Za-z0-9]|\s)*/g;
			value = e.detail.value.replace(pattern,'');
			this.setData({majorValidateCode: value})
		}
    },
	//点击导航切换
	handleIndexChange(e) {
		this.setData({
			tagAction: e.detail.active
		})
	},
	//是否勾选协议
	checkTap(e) {
		let needInvoice = e.target.dataset.agree;
		if (needInvoice == 0) {
			needInvoice = 1;
		} else {
			needInvoice = 0;
		}
		this.setData({needInvoice: needInvoice});
	},
	//分享功能
	onShareAppMessage() {
		return {
			title: '粤港澳直通车',
			desc: '粤港澳直通车',
			path: '/pages/handle/handle'
		}
	},

	getOptionsParam(options) {
		app.globalData.channelId = decodeURIComponent(options.scene) != 'undefined'?
								decodeURIComponent(options.scene) : app.globalData.channelId ? 
								app.globalData.channelId:'';
			console.log("channelId",app.globalData.channelId);	
	},

	onLoad(options) {
		let that = this;
		app.getOpenIdRender((num,openId) => {
			that.getOptionsParam(options); //获取扫码参数
		})
	},

	onShow() {
		let that = this;
		if (app.getStorageSync(app.globalData.paySuccessSign)) { //到达成功页，回复默认值
			this.setData({
				countDown: '获取验证码',
				majorCountDown: '获取验证码', //专业运输公司
				tagData: [
					{text: '非专业运输公司车辆', index: 1},
					{text: '专业运输公司车辆', index: 2}
				],
				//非专业公司参数
				archives: '', //受理编号
				preFix: 'Z', //默认前缀
				cardFix: '', //车牌号
				frame: '', //车架号
				code: '', //验证码
				phone: '', //内地手机号码
				phoneCode: '', //手机验证码
				validateCode: '', ////验证码
				codeImg: '', //验证码图片
				//专业公司参数
				dossier: '', //卷宗号
				idCard: '', //身份证
				name: '', //姓名
				majorCode: '', //验证码
				majorPhone: '',//内地手机号码
				majorPhoneCode: '',//手机验证码
				isShowFrame: false, //车身架号是否显示
				majorValidateCode : '', //验证码
				isShowMajorCode: false, //验证码弹框
				majorCodeImg: '', //验证图片
		
				needInvoice: 1,  //是否勾选
				isCanScroll: true, //屏幕是否能够滑动
				isShowFootNav: true,  //底部导航菜单
				tagAction: 1, //顶部导航默认选项
				preFixList: [
					{name: '粤Z',key: 'Z'}
				],
				isShowView: false //车牌前缀列表蒙层
			})
		}

		app.getOrderNum()
		app.getOpenIdRender((num,openId) => {
			that.setData({
				num: num
			})
		})

		let page = app.getStorageSync(app.globalData.cacheData);
		this.setData(Object.assign({}, page));
	},
	
	//底部切换页面方法
	toUrl(e) {
		let url = e.currentTarget.dataset.url;
		if(url!='/pages/fillInForm/fillInForm') { //点击不是当前页面
			app.setStorageSync(app.globalData.cacheData, this.data);
			if (url == '') {
				//develop（开发版），trial（体验版），release（正式版）
				let res = {
					appid: app.globalData.appid,
					path: '',
					envVersion: app.globalData.envVersion
				}
				app.crossToUrl(res)
			} else {
				app.redirectTo({url: url})
			}
		}
	},

	cacheData() {
		app.setStorageSync(app.globalData.cacheData, Object.assign({},this.data,{ popErrorMsg: '' },{errorScrollIntoViewName: ''},
			{errorFocusName:''}, {isCanScroll: true},{isShowModal: false},{countDown: '获取验证码'},{majorCountDown: '获取验证码'})); //保存状态在缓存 {countDown: '获取验证码'},{majorCountDown: '获取验证码'}
		app.removeStorageSync('tagSign')
		app.removeStorageSync(app.globalData.paySuccessSign)

	},

	onHide() {
		this.cacheData()
	},

	onUnload() {
		this.cacheData()
	},
	//确认提交按钮
	formSubmit(e) {
		// archives: '', //受理编号
		// preFix: 'A', //默认前缀
		// cardFix: '', //车牌号
		// frame: '', //车架号
		// code: '', //验证码
		// phone: '', //内地手机号码
		// phoneCode: '', //手机验证码
		let { tagAction, archives, preFix, cardFix, needInvoice, frame, code, phone, phoneCode, cardNbrIconType, frameIconType, codeIconType ,phoneIconType, phoneCodeIconType,
			dossier, idCard, name, majorCode, majorPhone, majorPhoneCode, dossierIconType, idCardIconType, nameIconType, majorCodeIconType, majorPhoneIconType, majorPhoneCodeIconType} = this.data,
			that = this;
		
		if (tagAction == 1) {
			let flag = app.check([
				{
					value: archives, //指标档案号
					errorFocusName: 'archives',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') {
							app.errorToast(FormCheckRule.archivesNullMessage);
							return false;
						} else {
							return true;
						}
					}
				},
				 {
					value: cardFix, //车牌号码
					errorFocusName: '',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') { 
							// app.errorToast(FormCheckRule.cardFixNullMessage);
							return true;
						} else if (cardNbrIconType == 'error') {
							that.setData({
								errorFocusName: 'cardFix'
							})
							app.errorToast(FormCheckRule.cardFixErrorMessage);
							return false;
						} else {
							if (frame == '') {
								that.setData({
									errorFocusName: 'frame'
								})
								app.errorToast(FormCheckRule.frameNullMessage);
								return;
							} else if (frameIconType == 'error') {
								that.setData({
									errorFocusName: 'frame'
								})
								app.errorToast(FormCheckRule.frameErrorMessage);
								return;
							}
							return true;
						}
					}
				},
				// {
				// 	value: frame, //车架号
				// 	errorFocusName: 'frame',
				// 	errorScrollIntoViewName: '',
				// 	fn: (value) => {
				// 		if (value == '') { 
				// 			app.errorToast(FormCheckRule.frameNullMessage);
				// 			return false;
				// 		} else if (frameIconType == 'error') {
				// 			app.errorToast(FormCheckRule.frameErrorMessage);
				// 			return false;
				// 		} else {
				// 			return true;
				// 		}
				// 	}
				// },


				//  {
				// 	value: code, //验证码
				// 	errorFocusName: 'code',
				// 	errorScrollIntoViewName: '',
				// 	fn: (value) => {
				// 		if (value == '') { 
				// 			app.errorToast(FormCheckRule.codeNullMessage);
				// 			return false;
				// 		} else if (codeIconType == 'error') {
				// 			app.errorToast(FormCheckRule.codeErrorMessage);
				// 			return false;
				// 		} else {
				// 			return true;
				// 		}
				// 	}
				// },
				{
					value: phone, //手机号码
					errorFocusName: 'phone',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.phoneNullMessage);
							return false;
						} else if (phoneIconType == 'error') {
							app.errorToast(FormCheckRule.phoneErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: phoneCode, //手机验证码
					errorFocusName: 'phoneCode',
					errorScrollIntoViewName: 'roll',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.phoneCodeNullMessage);
							return false;
						} else if (phoneCodeIconType == 'error') {
							app.errorToast(FormCheckRule.phoneCodeErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: needInvoice,  //勾选声明
					errorFocusName: '',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') {
							app.errorToast(FormCheckRule.checkService);
							return false;
						} else {
							return true;
						}
					}
				},
			]);
			if (!flag) {
				return false;
			}	
		} else {
			let flag = app.check([
				{
					value: dossier, //卷宗号
					errorFocusName: 'dossier',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') {
							app.errorToast(FormCheckRule.dossierNullMessage);
							return false;
						} else if (dossierIconType=='error') {
							app.errorToast(FormCheckRule.dossierErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: name, //姓名
					errorFocusName: 'name',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.nameNullMessage);
							return false;
						} else if (nameIconType == 'error') {
							app.errorToast(FormCheckRule.nameErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: idCard, //身份证号
					errorFocusName: 'idCard',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.idCardNullMessage);
							return false;
						} else if (idCardIconType == 'error') {
							app.errorToast(FormCheckRule.idCardErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, 
				// {
				// 	value: majorCode, //验证码
				// 	errorFocusName: 'majorCode',
				// 	errorScrollIntoViewName: '',
				// 	fn: (value) => {
				// 		if (value == '') { 
				// 			app.errorToast(FormCheckRule.majorCodeNullMessage);
				// 			return false;
				// 		} else if (majorCodeIconType == 'error') {
				// 			app.errorToast(FormCheckRule.majorCodeErrorMessage);
				// 			return false;
				// 		} else {
				// 			return true;
				// 		}
				// 	}
				// },
				 {
					value: majorPhone, //手机号码
					errorFocusName: 'majorPhone',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.majorPhoneNullMessage);
							return false;
						} else if (majorPhoneIconType == 'error') {
							app.errorToast(FormCheckRule.majorPhoneErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: majorPhoneCode, //手机验证码
					errorFocusName: 'majorPhoneCode',
					errorScrollIntoViewName: 'majorRoll',
					fn: (value) => {
						if (value == '') { 
							app.errorToast(FormCheckRule.majorPhoneCodeNullMessage);
							return false;
						} else if (majorPhoneCodeIconType == 'error') {
							app.errorToast(FormCheckRule.majorPhoneCodeErrorMessage);
							return false;
						} else {
							return true;
						}
					}
				}, {
					value: needInvoice,  //勾选声明
					errorFocusName: '',
					errorScrollIntoViewName: '',
					fn: (value) => {
						if (value == '') {
							app.errorToast(FormCheckRule.checkService);
							return false;
						} else {
							return true;
						}
					}
				},
			]);
			if (!flag) {
				return false;
			}	
		}

		if(!app.globalData.isAuthSuccess){
            app.toastAuthFailModal();
            return false;
		}
		
		let platform = '',
			formResult = {};
		if (app.isAndroid()) {
			platform = 'android'
        } else {
			platform = 'iPhone'
		}
		
		// return
		if (tagAction == 1) { //非专业
			formResult = {
				carArchivesNbr: archives, //'0002',//archives,  //指标档案号
				inlandCarNbr: cardFix?'粤' + preFix + cardFix : '', //'sdf',  //'粤' + preFix + cardFix, //车牌
				frameLastSix: frame, //'456456',//frame, //车架号
				inlandTelNbr: phone,//'13712312302', //内地手机号码  
				verifyCode: phoneCode, //手机验证码
				directType: 2
			}	
		} else { //专业
			formResult = {
				fileNbr: dossier,//'A0002', //dossier,  //卷宗号
				witnessName: name,//'张三',//name, //办证员姓名
				cardNbr: idCard,//'4401111',  //身份证号码
				inlandTelNbr: majorPhone,//'17820512885', //内地手机号码
				verifyCode: majorPhoneCode, //手机验证码
				directType: 1
			}	
		}
		formResult['payType'] = 0
		formResult['platform'] = platform
		formResult['formId'] = e.detail.formId
		let opt = {
			url: app.globalData.host+"/wx/hkmdc/qci.ajax",
			data: formResult,
			sucFn: (result) => {
				//canUseList  noUseList
				let data = result.body;
				if (tagAction == 1) { //非专业
					formResult['fileNbr'] = data.fileNbr
				}
				data['formResult'] = formResult
				app.setStorageSync(app.globalData.cachePayMnet, data);
				app.navigateTo({url:'../confirmOrder/confirmOrder'})
			}
		};
		app.ajax(opt);
	},

	//说明内容
	agreeTap(e) {
		app.navigateTo({url:'../agreement/agreement'})
	},
});
